import {
  get_list_api
} from '../../../api/other'
import {
  baseImgUrl
} from '../../../setting'
Page({
  data: {
    list: [],
    id: "",
    baseImgUrl: "",
    color:"#fff"
  },
  onLoad(e) {
   
    if (e && e.id) {
      this.setData({
        id: e.id
      })
    }
    this.setData({
      baseImgUrl: baseImgUrl
    })
    this.getList()
  },
  async getList() {
    const res = await get_list_api({
      id: this.data.id
      // this.data.id
    })
    my.setNavigationBar({
      title: res.title
    })
    this.setData({
      list: res.content,
      color:res.color
    })
    // console.log(baseImgUrl);
    // this.data.list.forEach(item => {
    //   if(item.id == 1) {
    //     console.log(item.form.imgUrl[0]);
    //   }
    // })
  },
  toChangePath(e) {
    const item = e.target.dataset.item.form
    if (item.type == 1) {
      my.navigateTo({
        url: `/pagesA/pages/webView/webView?id=${item.path}?jumpUrl=${item.link_url}`
      })
    } else if (item.type == 2) {
      console.log(item.page_url[item.page_url.length - 1]);
      my.navigateTo({
        url: `/${item.page_url[item.page_url.length - 1]}`
      })
    } else if (item.type == 3) {
       my.navigateTo({ url: '../../../pagesA/pages/productDetails/productDetails?goodsId=' + item.link_goods_id[0].goods_id })
    } else {}
  },
  toProd_ruter(e) {
    const goods_id = e.target.dataset.item.goods_id
    my.navigateTo({ url: '../../../pagesA/pages/productDetails/productDetails?goodsId=' +goods_id })
  }
});